<?php
    session_start();
    include_once '../../../../controlador/php/conexion/Conexion.php';
    $con = new Conexion();
    
    $oidbi = $_REQUEST['oidbi'];
    
    $upd = "select count(*)
            from controlTrans inner join lTransfunc on controlTrans.ltr_oid=lTransfunc.ltr_oid
            where lTransfunc.ltr_oid =".$oidbi." and ltr_estado = 2";
    
    $upd2 = $con->query($upd);
    $res = mssql_result($upd2, 0, 0);
    
    if($res == 1){
        $mensaje = "1";
    }else{
        
        $updc = "select count(*)
            from lTransfunc
            where lTransfunc.ltr_oid =".$oidbi." and ltr_estado = 2";
    
        $upd2c = $con->query($updc);
        $resc = mssql_result($upd2c, 0, 0);
        
        if($resc == 1){
            
        }else{
            $edi = "update lTransfunc
                set ltr_estado = 2,
                    ltr_fh = GETDATE()
                    where ltr_oid = ".$oidbi;

            $con->query($edi);
        }
        
        
    }
    
    
    $con->cerrarConexion();
    
    $lst = array('mensaje'=>$mensaje);
    print_r(json_encode($lst));
?>
